home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 February: Technology Seed / Mac Tech Seed Feb '97.toast / ODF Release 3 / ODF-Interest Archive / December 96 / Memory Containers.1 < prev    next >
Encoding:
Internet Message Format  |  1996-12-13  |  3.8 KB  |  [TEXT/ttxt]

  1. Subject:     Memory Containers
  2. Sent:        12/4/96 9:30 AM
  3. Received:    12/4/96 9:43 AM
  4. From:        Paul Mylchreest, paulm@teamsoft.com
  5. Reply-To:    ODF Interest, ODF-Interest@CILabs.ORG
  6. To:          OpenDoc Development Framework Discussion List, ODF-Interest@CILabs.
  7.  
  8. Dear ODF Community:
  9.  
  10. I am working on a way to store embedded parts into a database instead
  11. of the usual OpenDoc Bento Container.
  12.  
  13. To accomplish this, I have a CMemoryContainer class that uses a
  14. FW_PlatformHandle as
  15. a container obtained by way of CreateMemoryContainer().
  16.  
  17. Instances of this class also keep references to 
  18.     * the document: fContainer->AcquireDocument(ev, kODDefaultDocument);
  19.     * the draft: fDocument->AcquireBaseDraft(ev, kODDPExclusiveWrite);
  20.     * the storage unit: fDraft->AcquireDraftProperties(ev).
  21.  
  22. Moreover, to accuratly support data interchange, I have subclassed
  23. FW_CEmbeddingDataInterchange
  24. with CMemContainerDataInterchange and have overridden ExternalizeData() and
  25. InternalizeData().
  26.  
  27. Here is a snippet of InternalizeData()
  28. ==========
  29. FW_EInternalizeResult CMemContainerDataInterchange::InternalizeData(
  30.         Environment* ev, 
  31.         FW_CContent* content,
  32.         FW_CFrame* scopeFrame,
  33.         ODStorageUnit* sourceSU,
  34.         FW_StorageKinds storageKind, 
  35.         ODCloneKind cloneKind,
  36.         ODPasteAsResult* embedAsInfo)
  37. {
  38.     pTheContainer = FW_NEW(CMemoryContainer, (ev, sourceSU->GetSession(ev)));
  39.  
  40.     ODDraft
  41.         *fromDraft = sourceSU->GetDraft(ev),
  42. ==>        *dstDraft = pTheContainer->GetDraft();     // GET THE DRAFT FROM THE
  43. MEMORY CONTAINER (fDraft)
  44.  
  45.     // ... the rest is identical to
  46. FW_CEmbeddingDataInterchange::InternalizeData()
  47. }
  48. ==========
  49.  
  50. So, when I embed a part, it is internalized correctly and stored into my
  51. database.
  52. This works fine!
  53.  
  54. However, copying does not.  Here is a snippet of ExternalizeData()
  55. ==========
  56. void CMemContainerDataInterchange::ExternalizeData(
  57.         Environment* ev, 
  58.         FW_CContent* content,
  59.         FW_CFrame* scopeFrame,
  60.         ODStorageUnit* destinationSU, 
  61.         FW_StorageKinds storageKind, 
  62.         ODCloneKind cloneKind)
  63. {
  64.     if ((NULL != content) && (NULL != pTheContainer))
  65.     {
  66.         ODDraft
  67.             *fromDraft = pTheContainer->GetDraft(), // GET THE DRAFT FROM THE MEMORY
  68. CONTAINER (fDraft)
  69.             *dstDraft = destinationSU->GetDraft(ev);
  70.  
  71.         FW_CCloneInfo
  72.             cloneInfo(ev, fromDraft, scopeFrame, cloneKind);
  73.         
  74.         cloneInfo.BeginClone(ev, dstDraft);            
  75.         
  76. ==>        PrivHandleExternalizeData(ev, content, destinationSU, storageKind,
  77. &cloneInfo);
  78.  
  79.         cloneInfo.EndClone(ev);
  80.     }
  81. }
  82. ==========
  83.  
  84. then this gets called
  85.  
  86. ==========
  87. void
  88. FW_CEmbeddingDataInterchange::DoExternalizeSingleEmbeddedFrame(Environment*
  89. ev, 
  90.                                         ODFrame* odEmbeddedFrame, 
  91.                                         ODStorageUnit* destinationSU, 
  92.                                         FW_CCloneInfo* cloneInfo)
  93. {            
  94. //.....
  95.         
  96.     //    Clone the embedded part into the root storage unit.
  97.     FW_CAcquiredODPart aqPart = odEmbeddedFrame->AcquirePart(ev);
  98. ==>    ODID toRootID = cloneInfo->Clone(ev, aqPart->GetID(ev),
  99. destinationSU->GetID(ev), odEmbeddedFrame->GetID(ev));
  100.         
  101.         
  102. //.....
  103. }
  104. ==========
  105.  
  106.  
  107. ...and something goes terribly wrong in CMDraft.cpp:
  108.  
  109. ==========
  110. SOM_Scope void  SOMLINK CMDraftCloseCollections(CMDraft *somSelf,
  111. Environment *ev)
  112. {
  113. //.....
  114.             
  115. ==>    somSelf->Purge(ev, 0);
  116.     PurgeAllStorageUnits(ev, _fStorageUnits, _fIDList); // purge SU, relase
  117. CMObjects
  118.     
  119. //.....
  120. }
  121. ==========
  122.  
  123. ==>ODWarning: ODRefCntObject at 34c70f0 deleted with refcount == 1
  124.  
  125. here is the stack crawl:
  126.  
  127. FW_CCommand::Execute()
  128. FW_CClipboardCommand::DoIt()
  129. FW_CClipboardCommand::Copy()
  130. FW_CClipboardCommand::PrivCopy()
  131. CMemContainerDataInterchange::ExternalizeData()
  132. FW_CEmbeddingDataInterchange::PrivHandleExternalizeData()
  133. FW_CEmbeddingDataInterchange::DoExternalizeSingleEmbeddedFrame()
  134. FW_CCloneInfo::Clone()
  135. CMDraftCloseCollections()
  136.  
  137. Does anyone have any comments or suggestions on using Memory Containers.
  138. Thanks for any help.
  139.  
  140. ________________
  141. Paul Mylchreest
  142. Teamsoft Inc.
  143. Montreal, Quebec, Canada
  144. http://teamsoft.com
  145.  
  146.  
  147.  
  148.